package com.fy.service.service;

import com.fy.order.api.ProductOrderService;
import com.fy.order.dto.FindOrderDto;
import com.fy.order.dto.ObjectOrderDto;
import com.fy.service.entity.FindOrderEntity;
import com.fy.service.entity.ObjectOrderEntity;
import com.fy.service.mapper.ProductOrderMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.PostMapping;

import javax.annotation.Resource;
import java.util.List;

public class ProductOrderServiceImpl implements ProductOrderService {


    @Resource
    private ProductOrderMapper productOrderMapper;


    @Override
    @PostMapping(value = "/addTravelOrder")
    public ObjectOrderDto addProductOrder(ObjectOrderDto objectOrderDto) {
        ObjectOrderEntity objectOrderEntity = new ObjectOrderEntity();
        BeanUtils.copyProperties(objectOrderDto, objectOrderEntity);
        return productOrderMapper.addProductOrder(objectOrderEntity);
    }

    @Override
    public ObjectOrderDto objectOrderFindById(int objectOrderId) {
        return productOrderMapper.objectOrderFindById(objectOrderId);
    }

    @Override
    public List<ObjectOrderDto> objectOrderFindAll() {
        return productOrderMapper.objectOrderFindAll();
    }

    @Override
    public ObjectOrderDto findObjectOrder(FindOrderDto findOrderDto) {
        FindOrderEntity findOrderEntity = new FindOrderEntity();
        BeanUtils.copyProperties(findOrderDto, findOrderEntity);
        return productOrderMapper.findObjectOrder(findOrderEntity);
    }

    @Override
    public Boolean updateObjectOrder(ObjectOrderDto objectOrderDto) {
        ObjectOrderEntity objectOrderEntity = new ObjectOrderEntity();
        BeanUtils.copyProperties(objectOrderDto, objectOrderEntity);
        return productOrderMapper.updateObjectOrder(objectOrderEntity);
    }

    @Override
    public ObjectOrderDto updateObjectOrderState(int objectOrderId, int orderState) {
        return productOrderMapper.updateObjectOrderState(objectOrderId, orderState);
    }

    @Override
    public int deleteObjectOrderState(int objectOrderId) {
        return productOrderMapper.deleteObjectOrderState(objectOrderId);
    }

    @Override
    public ObjectOrderDto payObjectOrderState(int objectOrderId) {
        return productOrderMapper.payObjectOrderState(objectOrderId);
    }

    @Override
    public ObjectOrderDto deliveryUpdateObjectOrder(int objectOrderId, int orderDeliverNumber) {
        
        return productOrderMapper.deliveryUpdateObjectOrder(objectOrderId, orderDeliverNumber);
    }
}
